﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Lsk.Data;
using System.Data.Entity.Core.Objects;

namespace Lsk.Business
{
    public class Blog
    {
        private Lsk.Data.lskEntities _entity;
        public Blog()
        {
            _entity = new lskEntities();
        }

        public IEnumerable<GetBlog_Result> GetBlog(String url)
        {
            ObjectParameter resultType = new ObjectParameter("ResultType", typeof(string));
            ObjectParameter resultMessage = new ObjectParameter("ResultMessage", typeof(string));

            ObjectResult<GetBlog_Result> blog = _entity.GetBlog(url, resultType, resultMessage);

            return blog.AsEnumerable<GetBlog_Result>();
        }

        public IEnumerable<CreateBlog_Result> CreateBlog(String url, String title, String metatitle, String metadescription, String keywords, String contents)
        {
            ObjectParameter resultType = new ObjectParameter("ResultType", typeof(string));
            ObjectParameter resultMessage = new ObjectParameter("ResultMessage", typeof(string));

            ObjectResult<CreateBlog_Result> blog = _entity.CreateBlog(url, title, metatitle, metadescription, keywords, contents, resultType, resultMessage);

            return blog.AsEnumerable<CreateBlog_Result>();
        }

        public IEnumerable<UpdateBlog_Result> UpdateBlog(String url, String title, String metatitle, String metadescription, String keywords, String contents)
        {
            ObjectParameter resultType = new ObjectParameter("ResultType", typeof(string));
            ObjectParameter resultMessage = new ObjectParameter("ResultMessage", typeof(string));

            ObjectResult<UpdateBlog_Result> blog = _entity.UpdateBlog(url, title, metatitle, metadescription, keywords, contents, resultType, resultMessage);

            return blog.AsEnumerable<UpdateBlog_Result>();
        }

        public IEnumerable<DeleteBlog_Result> DeleteBlog(String url)
        {
            ObjectParameter resultType = new ObjectParameter("ResultType", typeof(string));
            ObjectParameter resultMessage = new ObjectParameter("ResultMessage", typeof(string));

            ObjectResult<DeleteBlog_Result> blog = _entity.DeleteBlog(url,resultType, resultMessage);

            return blog.AsEnumerable<DeleteBlog_Result>();
        }
    }
}
